package com.example.springretest.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class TestAop {

    @Pointcut("execution(* com.example.springretest.controller.TestController.*(..))")
    public void pointcut() {

    }
    @After("pointcut()")
    public void afterAdvice() {
        System.out.println("执行了后置通知！");
    }
    @Before("pointcut()")
    public void beforeAdvice() {
        System.out.println("执行了前置通知！");
    }
    @Around("pointcut()")
    public Object aroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("开始执行环绕通知~！");
        Object obj = null;
        obj = joinPoint.proceed();
        System.out.println("退出环绕通知~!");
        return obj;
    }
}
